﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace DDS.WebControls
{
    /// <summary>
    ///DDS_WebControls_PanelBar 的摘要说明
    /// </summary>
    public class PanelBar
    {
        public string ID { get; set; }

        public System.Collections.Generic.List<PanelBarGroup> PanelBarGroups = new System.Collections.Generic.List<PanelBarGroup>();

        public PanelBar(string id)
        {
            ID = id;
        }

        public string DataBind()
        {
            string html = string.Empty;
            html += "<div style='width: 100%' id='" + ID + "' class='DDSPanelBar DDSPanelBar_Black'> <ul class='rpRootGroup'>";
            if (PanelBarGroups != null)
            {
                foreach (PanelBarGroup group in PanelBarGroups)
                {
                    html += @"<LI class='rpItem'><A class='rpLink rpExpandable' 
        href='" + group.NavigateUrl + @"'><SPAN 
        class=rpText style='color:White;'>" + group.Text + @"</SPAN></A>" + group.CreateHtml() + "</LI>";
                }
            }
            html += "</ul><div>";
            return html;
        }

    }

    public class PanelBarGroup
    {
        public string NavigateUrl { get; set; }

        public bool Expanded { get; set; }

        public string Text { get; set; }

        public string Value { get; set; }

        public System.Collections.Generic.List<PanelBarItem> PanelBarItems = new System.Collections.Generic.List<PanelBarItem>();

        public string CreateHtml()
        {
            string html = string.Empty;
            if (PanelBarItems != null)
            {
                foreach (PanelBarItem item in PanelBarItems)
                {
                    html += @"
        <DIV style='DISPLAY: block' class=rpSlide>
        <UL style='DISPLAY: block' class='rpGroup rpLevel1 '>
          <LI class='rpItem'><A class=rpLink 
          href='" + item.NavigateUrl + @"' 
          target=" + item.Target + @"><SPAN 
        class=rpText>" + item.Text + @"</SPAN></A></LI></UL></DIV>";
                }
            }
            return html;
        }
    }

    public class PanelBarItem
    {
        public string NavigateUrl { get; set; }

        public string Text { get; set; }

        public string Target { get; set; }

        public string Value { get; set; }
    }
}
